﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MODULE_KCS
{
    public class cls_kcs
    {
        public System.Windows.Forms.Form parent;
        private string macongty;
        public string _macongty
        {
            get { return macongty; }
            set { macongty = value; }
        }
         public static kcsDataContext getcontext()
        {
            kcsDataContext context = new kcsDataContext(getconnectstring());
            return context;
        }
        public void ShowForm(string formname)
        {

            switch (formname)
            {
                case "frm_kcs":
                    frm_kcs frmnh = new frm_kcs();
                    frmnh.MdiParent = parent;
                    frmnh.Show();
                   
                    break;
                case "frm_choncongty":
                    frm_inphieubiennhan frmchoncongty = new frm_inphieubiennhan();
                    frmchoncongty.MdiParent = parent;
                    frmchoncongty.Show();
                    
                    break;

            }
        }
       public static string getconnectstring()
        {
            string kq = "";
            XmlDocument MyDoc = new XmlDocument();

            MyDoc.Load("extension\\extension.xml");
            XmlNode root = (XmlNode)MyDoc.DocumentElement;

            for (int i = 0; i < root.ChildNodes.Count; i++)
            {
                XmlNode element = (XmlNode)root.ChildNodes[i];
                if (element.Name == "connection")
                {
                    kq = element.Attributes["connectionString"].Value.ToString();
                }
            }
            return kq;

        }
    }
}
